home *** CD-ROM | disk | FTP | other *** search
/ Interactive Media Design Review 1999 / Interactive Media Design Review 1999.iso / pc / allfiles / Centri / Centri.dir / 00252_Script_Sprite Blender < prev    next >
Text File  |  1999-02-25  |  2KB  |  60 lines

  1. property startBlend
  2. -- how far away should the fade begin?
  3. property StartFadePoint 
  4.  
  5. -- how far away should the fade stop 
  6. -- (at which point the blend should = 100) ?
  7.  
  8. property EndFadePoint
  9.  
  10.  
  11. on beginSprite me -- sets initial blend
  12.   puppetsprite  the spriteNum of me, 1
  13.   set the blend of sprite the spriteNum of me = startBlend
  14.   updatestage
  15. end
  16.  
  17. on exitFrame me -- provides the trigger for the blend updates
  18.   sendSprite  (the spritenum of me, #blendit)
  19. end
  20.  
  21.  
  22. on blendSprite which, what -- does the blending :)
  23.   set the blend of sprite which = what
  24.   updatestage
  25. end  
  26.  
  27. on blendit me 
  28.   set dv = abs((the locV of sprite the spriteNum of me) - the mousev)
  29.   set  dH = abs((the locH of sprite the spriteNum of me) - the mouseh)
  30.   set distance = sqrt( dV * dV + dH * dH ) 
  31.   if distance < EndFadePoint then
  32.     blendSprite the spriteNum of me,100 
  33.     exit
  34.   end if
  35.   if distance < StartFadePoint then
  36.     set percentage = (distance*100/StartFadePoint) 
  37.     set blendToValue =  (100-percentage)
  38.     if blendToValue < startBlend then set blendToValue =  startBlend 
  39.     blendSprite the spriteNum of me,blendToValue 
  40.   else
  41.     blendSprite the spriteNum of me,startBlend 
  42.   end if
  43.   updatestage
  44. end
  45.  
  46. on getPropertyDescriptionList
  47.   set p_list = [¼
  48.                           #startBlend: [ #default:0, #format:#integer, #comment:"Initial Blend",#range: [#min:0,#Max:100]] ,¼
  49.                              #StartFadePoint: [ #default:200, #format:#integer, #comment:"Trigger Point", #range:[#min:0,#Max:500]],¼
  50.                              #EndFadePoint: [ #default:20, #format:#integer, #comment:"End Trigger Point", #range:[#min:0,#Max:50]] ¼
  51.                           ]
  52.   return p_list
  53. end
  54.  
  55.  
  56. on getBehaviorDescription
  57.   return  "Creates sprites that fade in and out (using the sprite blend property) depending how far they are from the mouse. " &return&return&¼
  58.                           "Try different inks for your sprites - different images require different settings. Also, there appears to be a bug in Director 6 that prevents sprites with a blend of 0 from being totally hidden. "
  59.   
  60. end